package net.zigin.nhi.could.waste.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import net.zigin.nhi.could.waste.dto.WarnBaseDto;
import net.zigin.nhi.could.waste.service.WarnBaseService;

import net.zigin.nhi.could.waste.vo.JsonForResult;
import net.zigin.nhi.could.waste.vo.WarnBaseVo;
import net.zigin.nhi.could.waste.vo.WasteWarnVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * WarnBase控制器类
 * @ClassName: WarnBaseController
 * @author mgw1986
 * @date 2021-9-23 23:25:03
 * @version V1.0
 */
@Api(tags = "预警管理")
@RestController
@RequestMapping("/warnBase")
public class WarnBaseController extends BaseController {
	@Autowired
	private WarnBaseService warnBaseService;

	@ApiOperation("预警列表")
	@ApiImplicitParam(name = "warnBaseDto", value = "预警信息", required = true, dataType = "WarnBaseDto")
	@PostMapping("/getList")
	public JsonForResult<List<WarnBaseVo>> getList(@RequestBody WarnBaseDto warnBaseDto) {
		List<WarnBaseVo> list = warnBaseService.getList(warnBaseDto);
		Integer count = warnBaseService.getCount(warnBaseDto);
		return JsonForResult.<List<WarnBaseVo>>builder().data(list).total(count).success(true).build();
	}


	@ApiOperation("预警处理")
	@ApiImplicitParam(name = "warnBaseDto", value = "预警信息", required = true, dataType = "WarnBaseDto")
	@PostMapping("/dealWith")
	public JsonForResult dealWith(@RequestBody WarnBaseDto warnBaseDto) {
		warnBaseService.dealWith(warnBaseDto);
		return JsonForResult.builder().success(true).build();
	}

	@ApiOperation("获取时间重量")
	@ApiImplicitParam(name = "wasteBaseId", value = "医废ID", required = true, dataType = "String")
	@GetMapping("/getWarnTimeAndWeight/{wasteBaseId}")
	public JsonForResult<WasteWarnVo> getWarnTimeAndWeight(@PathVariable("wasteBaseId") String wasteBaseId){
		WasteWarnVo wasteWarnVo = warnBaseService.getWarnTimeAndWeight(wasteBaseId);
		return JsonForResult.<WasteWarnVo>builder().data(wasteWarnVo).success(true).build();
	}

}
